# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

pkgname=qhexedit2
pkgver=0.8.9
pkgrel=1
pkgdesc='Hex editor widget written in C++ for the Qt framework'
url='https://github.com/Simsys/qhexedit2'
arch=(loong64 x86_64)
license=(LGPL)
depends=(qt5-base)
makedepends=(cmake qt5-tools)
provides=(libqhexedit.so)
options=(debug)
source=(${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('2c32d0fde1685e9af7978ba60002a7d9fad4f2f3d0d1c4b19bdc18ab74b69e41')
b2sums=('901cda2d28074bb535426102e40e0d5b6e68d3659b16ab4755b124de1f8a0ca878494e537f2c44b19dfc7bd9b9db499e74f66bd42301a73d12830486b7883d02')

build() {
  cd ${pkgname}-${pkgver}

  msg2 'Building qt library'
  qmake-qt5 src/qhexedit.pro
  make

  msg2 'Building tests'
  pushd test
  qmake-qt5 chunks.pro
  make
  mkdir logs
  popd

  msg2 'Building pkgconfig'
  cat > ${pkgname}.pc <<EOF
prefix=/usr
libdir=\${prefix}/lib
includedir=\${prefix}/include/${pkgname}

Name: ${pkgname}
Description: ${pkgdesc}
Version: ${pkgver}
Cflags: -I\${includedir}
Libs: -L\${libdir} -lqhexedit
EOF
}

check() {
  cd ${pkgname}-${pkgver}/test
  ./chunks
}

package() {
  cd ${pkgname}-${pkgver}
  install -Dm 644 src/*.h -t "${pkgdir}/usr/include/${pkgname}"
  install -d "${pkgdir}/usr/lib"
  cp -a *.so* "${pkgdir}/usr/lib"
  install -Dm 644 ${pkgname}.pc -t "${pkgdir}/usr/share/pkgconfig"

  install -Dm 744 readme.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dm 744 src/license.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
